1234567891011121314151617181920212223242526272829303132 |
-
- IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'Vw_TwoSalesOrder')
- BEGIN
- DROP VIEW [dbo].Vw_TwoSalesOrder
- END
- GO
- create View Vw_TwoSalesOrder
- as
- SELECT
- dbo.tb_ErpTwoSalesOrder.ID,
- Tsorder_Number,
- Tsorder_Name,
- (case Tsorder_CustomerName
- when '' then (select Cus_Name from tb_ErpCustomer where Tsorder_CustomerNumber=Cus_CustomerNumber)
- else Tsorder_CustomerName end) as Tsorder_CustomerName,
- (case Tsorder_CustomerName
- when '' then (select Cus_Telephone from tb_ErpCustomer where Tsorder_CustomerNumber=Cus_CustomerNumber)
- else Tsorder_Telephone end) as Tsorder_Telephone,
- (select Cus_NamePinyin from tb_ErpCustomer where Tsorder_CustomerNumber=Cus_CustomerNumber) as Cus_NamePinyin,
- Tsorder_Money,
- Tsorder_Quantity,
- Tsorder_Category,
- Tsorder_OpenSingle,
- Tsorder_PersonHandling,
- Tsorder_Remark,
- Tsorder_CreateDatetime,
- Tsorder_UpdateDatetime,
- dbo.fn_CheckUserIDGetUserName(Tsorder_OpenSingle) AS [User_Name],
- dbo.fn_CheckUserIDGetUserName(Tsorder_PersonHandling) AS Tsorder_PersonHandlingName,
- dbo.fn_GetClassCodeToName(Tsorder_Category,Tsorder_Category) AS Tsorder_CategoryName,
- Tsorder_CustomerNumber
- FROM dbo.tb_ErpTwoSalesOrder
|